package com.example.blog.Service;

import com.example.blog.model.BlogInfo;
import com.example.blog.mapper.BlogInfoMapper;
import com.example.blog.model.PageRequest;
import com.example.blog.model.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//先写后端，先测试后端，再去写前端，再去测试
@Service
public class BlogInfoService {
    @Autowired
    public BlogInfoMapper blogMapper;
    public PageResult selectAllBlogByPage(PageRequest pageRequest){
        Integer count =blogMapper.count();
        List<BlogInfo>blogList=blogMapper.queryBlogListByPage(pageRequest);
        return new PageResult(blogList,count,pageRequest);
    }
    public Integer InsertBlog(BlogInfo blog){
        return blogMapper.insertBlog(blog);
    }
    public BlogInfo selectById(Integer id) {
        return  blogMapper.queryBlogById(id);
    }
    public Integer deleteDetailById(Integer id){
        return  blogMapper.DeleteBlogById(id);
    }
    public Integer updateBlogById(BlogInfo blogInfo){
        return  blogMapper.updateBlogById(blogInfo);
    }
}
